package Chapter5;

import java.util.Arrays;
//105页程序5.3
public class ArrayCopy {
    public static void main(String[] args) {
        int[] a1 ={1,2,3,4,5};
        int[] a ={1,4,2,5,7,8,3,2,5,6};
        System.arraycopy(a1,1,a,4,3);//将数组a1中下标为1的元素开始，取3个元素复制到数组a的下标为4的位置
        System.out.println("复制数组得到的数组a = " + Arrays.toString(a));//将改变数组元素的a通过数组元素转字符串并打印

        int[] b ={1,4,2,5,7,8,3,2,5,6,3,2,5,6};
        Arrays.fill(b,3,9,5);  //将数组b中下标为3的元素开始，直到下标为9之前的元素，将值全部替换为5
        System.out.println("替换数值得到的数组b = "+Arrays.toString(b));

        int[] c ={8,1,4,2,3,5,7,6,9};
        Arrays.sort(c);
        System.out.println("升序排序得到的数组c = "+Arrays.toString(c));//将数组c的元素进行升序排列

        int[] d1 ={8,1,4,2,3,5,7,6,9,1,4,2,3,5,7,6,1,4,2,3,5,7,6,1,4,2,3,5,7,6};
        int[] d ={8,1,4,2,3,5,7,6,9,1,4,2,3,5,7,6,1,4,2,3,5,7,6,1,4,2,3,5,7,6};
        System.out.println("判断两个数组的值是否相同 = "+Arrays.equals(d1,d));//比较两个相同基本数据类型的数组的值，也可判断类类型

        int[] e ={1,4,2,5,7,8,3,2,2,5,6};
        System.out.println("查找数组是否包含某值 = "+Arrays.binarySearch(e,3));
        //该方法存疑https://blog.csdn.net/Jerrychd/article/details/129922943

    }
}
